
<%@page import="com.mx.im.sinocab.bean.Option"%>
<%@page import="com.mx.im.sinocab.bean.Menu"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.mx.im.sinocab.bean.User"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
    String contextPath = request.getContextPath();
    String dateToday = request.getSession().getAttribute("dateToday") != null ? request.getSession().getAttribute("dateToday").toString() : "noDate";
    User userLogin = request.getSession().getAttribute("user") != null ? (User) request.getSession().getAttribute("user") : new User();
    ArrayList listMenuOptionsIndex = request.getSession().getAttribute("sesionListMenuOptions") != null ? (ArrayList) request.getSession().getAttribute("sesionListMenuOptions") : new ArrayList();
    if (!(request.getSession().getAttribute("activeSesion") != null ? Boolean.parseBoolean(request.getSession().getAttribute("activeSesion").toString()) : false)) {
        request.setAttribute("message", "¡Por favor, inicia sesión!");
        request.setAttribute("messageType", "error");
%>


<jsp:forward page="../body/index.jsp"></jsp:forward>
<%}%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Sistema de Nómina y Control de acceso biométrico V 1.0</title>

        <link rel="stylesheet" href="<%=contextPath%>/Css/StyleAlert/StyleAlert.css" type="text/css"  />

        <script type="text/javascript" src="<%=contextPath%>/JS/JQuery/jquery.min.js"></script>
        <script type="text/javascript" src="<%=contextPath%>/JS/JQuery/jquery.easing.1.3.js"></script>
        <script type="text/javascript" src="<%=contextPath%>/JS/JQuery/sexyalertbox.v1.2.jquery.js"></script>
        <script src="<%=contextPath%>/JS/JQuery/jquery.js" type="text/javascript"></script>

        <link rel="stylesheet" href="<%=contextPath%>/Css/css.css" type="text/css"  />   
        <link rel="stylesheet" href="<%=contextPath%>/Css/styleMenu.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="<%=contextPath%>/Css/AlertStyle/StyleAlert.css" type="text/css"  />
        <link rel="stylesheet" href="<%=contextPath%>/Css/Watermark.css" type="text/css"/>

        <link rel="stylesheet" href="<%=contextPath%>/Css/JQuery/jquery-ui.css" />
        <script src="<%=contextPath%>/JS/JQuery/jquery-1.9.1.js"></script>
        <script src="<%=contextPath%>/JS/JQuery/jquery-ui.js"></script>



        <script type="text/javascript" src="<%=contextPath%>/JS/JQuery/jquery.easing.1.3.js"></script>

    </head>
    <body bgcolor="#ffffff" onload="javascript: onloadScript();">

        <div class="example">
            <ul id="nav">
                <li class="current"><a href="<%=contextPath%>/Jsp/body/JspMainMenu.jsp">Home</a></li>



                <%     int countIndex = 0;
                    for (Object globalObject : listMenuOptionsIndex) {
                        ArrayList finalMenu = (ArrayList) globalObject;
                        Menu menu = (Menu) finalMenu.get(0);
                        ArrayList<Option> options = (ArrayList<Option>) finalMenu.get(1);
                        System.out.println("data: " + finalMenu);
                        countIndex++;
                %>

                <li><a href="#"><%=menu.getMenu()%></a>

                    <% if (!(options.isEmpty())) {%>
                    <ul>
                        <% for (Option option : options) {%>

                        <% if (option.isStatus()) {
                                if (option.getActionRequest().equals("#") || option.getActionRequest().equals("")) {
                        %>
                        <li><a href="#"><%=option.getOption()%></a></li>
                        <%} else {%>
                        <li><a href="<%=contextPath%><%=option.getActionRequest()%>"><%=option.getOption()%></a></li>
                        <%}
                                }
                            }%>
                    </ul>

                    <%}
                        }%>
                </li>


                <li>
                    <a href="#">
                        <table style="">
                            <tr>
                                <td>
                                    <% if (userLogin.getEmploy().getGender().equals("M")) {%>
                                    <img src="<%=request.getContextPath()%>/Img/userman.png" title="Agregar opción" width="30px" height="30px"  />
                                    <%} else {%>
                                    <img src="<%=request.getContextPath()%>/Img/userGirl.png" title="Agregar opción" width="30px" height="30px"  />
                                    <%}%>
                                </td><td style="font-size: 13px; color: white;">

                                    <%=userLogin.getEmploy().getName()%>
                                </td>
                            </tr>
                        </table>
                    </a>
                    <ul>
                        <li><a href="<%=contextPath%>/LogoutAction.do">Salir</a></li>
                        <li><a href="#">Cambiar de usuario</a></li>
                        <li><a href="#">Seguridad</a>
                            <ul>
                                <li><a href="#">Actualiza contraseña</a></li>
                                <li><a href="#">Privacidad</a></li>
                                <li><a href="#">Bloquea mi cuenta</a></li>
                                <li><a href="#">Reporta un problema</a></li>
                            </ul>
                        </li> 
                    </ul>
                </li>
                <div style=" margin-top: 19px; color: white; margin-right: 10px;" align="right"  ><%=dateToday%></div>
            </ul>
            <script type="text/javascript" >
                function onloadScript() {
                <%
                    String messageType = (String) request.getAttribute("message") != null ? request.getAttribute("messageType").toString() : "";
                    String message = (String) request.getAttribute("message") != null ? request.getAttribute("message").toString() : "";

                    try {
                        if (messageType != "" && message != "") {%>
                                Sexy.<%=messageType%>("<%=message%>");
                <%
                            request.removeAttribute("message");
                        }
                    } catch (NullPointerException npe) {
                        npe.printStackTrace();
                    } finally {
                    }
                %>
                        onloadBody();
                    }
            </script>
